<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>super必须放在子类构造器的前面</title>
</head>
<body>
<script>
    class Father{
        constructor(x,y) {
            this.x = x;
            this.y = y;
        }
        sum() {
            console.log(this.x + this.y);
        }
    }
    class Son extends Father {
        constructor(x,y) {
            super(x,y);//调用父类的构造函数必须放在构造器的开始
            this.x = x;
            this.y = y;
        }
        sub() {
            console.log(this.x - this.y);
        }
    }
    var son = new Son(3,2);
    son.sub();
    son.sum();
</script>
</body>
</html>